package com.timing;

import java.util.concurrent.TimeUnit;

import com.game.majiang.config.LogManager;
import com.game.majiang.logic.LogicTable;
import com.game.server.system.AbstractRoom;
import com.game.server.system.AbstractTable;

public class RoomTask extends TimingTasks{

	private final AbstractRoom room;
	
	public RoomTask(AbstractRoom room) {
		super();
		this.room = room;
		threadPool.scheduleWithFixedDelay (new TimeEvent(), 5L,1L, TimeUnit.SECONDS);
	}

	 class TimeEvent implements Runnable{

		@Override
		public void run() {
			if (room != null) {
				for (AbstractTable abtble : room.getTables()) {
					LogicTable table = (LogicTable) abtble;

					//LogManager.getInstance().Log("房间不为空getID:"+table.getID());
				//	LogManager.getInstance().Log("房间不为空getWatchWar() "+table.getWatchWar());
					try {

						table.timeEvent();

					} catch (Exception e) {
						LogManager.getInstance().errorLog(e);
					}
				}
			}
			
		}
		
		
		
	}

	

	
}
